
use "mcss_prep/datasource/emp_79_09.dta", clear
*this is the dataset on European manifestos

***the original dataset is taken from https://dbk.gesis.org/dbksearch/download.asp?db=E&id=60661 

***the codes for 2009 and 2014 have been changed
**however, here are the new codes as used in Tavits 2008 transformed
*v1, v2, v3 stand for mention in national, european or other context

set more off
recode per_v1_101b-per_v3_7064a (-999=0) (.=0)
recode seats (-888=.)


gen er403=per_v1_403a+per_v2_403a+per_v3_403a

gen er402=per_v1_402a+per_v2_402a+per_v3_402a

gen er404=per_v1_404a+per_v2_404a+per_v3_404a

gen er4012=per_v1_412b+per_v2_412b+per_v3_412b

gen er406=per_v1_406a+per_v2_406a+per_v3_406a

gen er407=per_v1_406b+per_v2_406b+per_v3_406b

gen er412=per_v1_412a+per_v2_412a+per_v3_412a

gen er413=per_v1_413a+per_v2_413a+per_v3_413a

gen er401=per_v1_401a+per_v2_401a+per_v3_401a

gen er503=per_v1_503a+per_v2_503a+per_v3_503a

gen er504=per_v1_504a+per_v2_504a+per_v3_504a

gen er505=per_v1_504b+per_v2_504b+per_v3_504b

gen er506=per_v1_506a+per_v2_506a+per_v3_506a

gen er507=per_v1_506b+per_v2_506b+per_v3_506b

gen er4132=per_v1_4132a+per_v2_4132a+per_v3_4132a

gen er4123=per_v1_4123a+per_v2_4123a+per_v3_4123a

** per4011 is something else [structural funds] in the European manifesto study

gen er4131=per_v1_4132b+per_v2_4132b+per_v3_4132b

gen er4124=per_v1_4124a+per_v2_4124a+per_v3_4124a

gen er4013=per_v1_4012a+per_v2_4012a+per_v3_4012a

gen er409=per_v1_409a+per_v2_409a+per_v3_409a

gen er410=per_v1_410a+per_v2_410a+per_v3_410a

***retrieve the number of quasi sentences from the percentages

foreach v of varlist er403-er410 {

gen pt`v'=`v'/100*total

gen p`v'=round(pt`v', 1)
}

drop per_*

rename party partyid

keep country partyid year seats per*
drop persid

gen lr1 = log(per402+0.5) - log(per403+0.5)
gen lr2 = log(per4012+0.5) - log(per404+per409+0.5)
gen lr3 = log(per407+per410+0.5) - log(per406+0.5)
gen lr4 = log(per401+0.5) - log(per412+per413+0.5)
gen lr5 = log(per505+0.5) - log(per503+per504+0.5)
gen lr6 = log(per507+0.5) - log(per506+0.5)
gen lr7 = log(0.5) - log(per4132+per4123+0.5)
gen lr8 = log(per4013+0.5) - log(per4131+per4124+0.5)

drop per*

rename partyid party

gen party2=string(party)

gen year2="79" if year==1979
replace year2="84" if year==1984
replace year2="87" if year==1987
replace year2="96" if year==1996
replace year2="95" if year==1995

replace year2="89" if year==1989
replace year2="94" if year==1994
replace year2="99" if year==1999
replace year2="04" if year==2004
replace year2="09" if year==2009

gen eind_id=party2+"."+year2
drop party*
move eind_id year

keep if country==80|country==82|country==83|country==86|country==87|country==88|country==92|country==93| ///
country==96|country==97
saveold "mcss_prep/datasource/EMP_79_2009_short_east.dta", version(12) replace









